// pages/initiaterefund/initiaterefund.js
const util = require("../../utils/util.js");
var app = getApp();
const requestManager = require("../../utils/request.js");
var router = require('../../utils/router.js');
const pageName = "PersonalCenter "
Page({

  /**
   * 页面的初始数据
   */
  data: {
    orderRes: null,
    detailData: null
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    this.getDetaildata(options.orderId)
  },
  //获取订单详情数据
  getDetaildata(productid) {
    let params = {
      userId: util.getUserInfo().userId,
      id: productid || 82854
    }
    requestManager.getDataResult(requestManager.order_view, params, "GET").then(res => {
      this.setData({
        detailData: res.data
      })
      let params = {
        userId: util.getUserInfo().userId,
        orderId: res.data.id,
        serviceId: res.data.serviceId
      }
      requestManager.getDataResult(requestManager.service_view, params, "GET").then(orderRes => {
        this.setData({
          orderRes: orderRes.data
        })
        console.log(orderRes.data)
      })
    })
  },
  /*
  撤销申请
  */
  cancelApplication(event) {
    wx.showLoading()
    let params = {
      userId: util.getUserInfo().userId,
      orderId: this.data.detailData.id,
      serviceId: this.data.detailData.serviceId
    }
    // 取消售后列表
    requestManager.getDataResult(requestManager.order_service_revoke, params, "GET").then(res => {
      wx.hideLoading()
      let url = "/pages/orderList/orderList";
      router.route.setAction(router.NAVIGATE_TO)
        .setParams([`order=shouhou`])
        .setUrl(url)
        .run()
    }).catch(err => {
      wx.hideLoading()
    })
  },
  /*
  修改申请
  */
  handleChange() {
    let url = "/pages/reimburse/reimburse";
    router.route.setAction(router.NAVIGATE_TO)
      .setParams([`id=${this.data.detailData.shipType ? this.data.detailData.shipType : 1}&orderId=${this.data.detailData.id}`])
      .setUrl(url)
      .run()
  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})